package com.xxk.wdis.utills;

/**
 * @author ：chenwenbin
 * @date ：Created in 2020/01/21 11:32
 * @description ：用于返回结果的Bean,用于统一返回格式
 */
public class HisResult {
    /**
     * http 状态码
     */
    private int code;
    /**
     * 返回信息
     */

    private String msg;
    /**
     * 返回数据
     */
    private Object data;

    public HisResult(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static HisResult build(int code, String msg, Object data) {
        return new HisResult(code, msg, data);
    }

    public static HisResult ok(String msg, Object data) {
        return new HisResult(200, msg, data);
    }

    public static HisResult ok(Object data) {
        return new HisResult(200, "ok", data);
    }

    public static HisResult ok() {
        return new HisResult(200, "ok", null);
    }

    public static HisResult error(String msg, Object data) {
        return new HisResult(-1, msg, data);
    }

    public static HisResult error(String msg) {
        return new HisResult(-1, msg, null);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
